package com.ruoyi.protocolTemplate.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.protocolTemplate.domain.ProtocolTemplate;
import com.ruoyi.protocolTemplate.mapper.ProtocolTemplateMapper;
import com.ruoyi.protocolTemplate.service.IProtocolTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 协议模板Service业务层处理
 *
 * @author jiuyou
 * @date 2021-07-09
 */
@Service
public class ProtocolTemplateServiceImpl implements IProtocolTemplateService
{
    @Autowired
    private ProtocolTemplateMapper protocolTemplateMapper;

    /**
     * 查询协议模板
     *
     * @param id 协议模板ID
     * @return 协议模板
     */
    @Override
    public ProtocolTemplate selectProtocolTemplateById(Long id)
    {
        return protocolTemplateMapper.selectProtocolTemplateById(id);
    }

    /**
     * 查询协议模板列表
     *
     * @param protocolTemplate 协议模板
     * @return 协议模板
     */
    @Override
    public List<ProtocolTemplate> selectProtocolTemplateList(ProtocolTemplate protocolTemplate)
    {
        return protocolTemplateMapper.selectProtocolTemplateList(protocolTemplate);
    }

    /**
     * 新增协议模板
     *
     * @param protocolTemplate 协议模板
     * @return 结果
     */
    @Override
    public int insertProtocolTemplate(ProtocolTemplate protocolTemplate)
    {
        protocolTemplate.setCreateTime(DateUtils.getNowDate());
        return protocolTemplateMapper.insertProtocolTemplate(protocolTemplate);
    }

    /**
     * 修改协议模板
     *
     * @param protocolTemplate 协议模板
     * @return 结果
     */
    @Override
    public int updateProtocolTemplate(ProtocolTemplate protocolTemplate)
    {
        protocolTemplate.setUpdateTime(DateUtils.getNowDate());
        return protocolTemplateMapper.updateProtocolTemplate(protocolTemplate);
    }

    /**
     * 批量删除协议模板
     *
     * @param ids 需要删除的协议模板ID
     * @return 结果
     */
    @Override
    public int deleteProtocolTemplateByIds(Long[] ids)
    {
        return protocolTemplateMapper.deleteProtocolTemplateByIds(ids);
    }

    /**
     * 删除协议模板信息
     *
     * @param id 协议模板ID
     * @return 结果
     */
    @Override
    public int deleteProtocolTemplateById(Long id)
    {
        return protocolTemplateMapper.deleteProtocolTemplateById(id);
    }

    @Override
    public ProtocolTemplate selectProtocolTemplateByCode(String code) {
        return protocolTemplateMapper.selectProtocolTemplateByCode(code);
    }
}
